{include file="common:header" /}
{include file="common:side" /}
    <div id="page-wrapper">
      <!-- 舆情日报 -->
      <!--*************************** content部分开始 ******************-->
      <div class="container-fluid" id="m_main">
        <div class="row m-t-20">
          <div class="col-sm-12">
            <div class="white-box">
              <h2 class="box-title m-b-20">添加班级信息</h2>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">班级名称：</label>
                    <input type="text" class="form-control" placeholder="" v-model="name">
                  </div>
                </div>
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">主教老师：</label>
                    <select class="selectpicker" data-style="form-control" v-model="master_teacher">
                      <option value="">请选择</option>
                      {foreach $teacher_list as $key=>$vo } 
                      <option value="{$vo.id}">{$vo.name}</option>
                      {/foreach}
                    </select>
                  </div>
                </div>
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">助教老师：</label>
                    <select class="selectpicker" data-style="form-control" v-model="assistant_teacher">
                      <option value="">请选择</option>
                      {foreach $teacher_list as $key=>$vo } 
                      <option value="{$vo.id}">{$vo.name}</option>
                      {/foreach}
                    </select>
                  </div>
                </div>
              </div>
              <div class="row m-t-40">
                <div class="col-sm-8 ta-c">
                  <button type="button" name="" class="btn btn-outline btn-primary m-r-40" @click="doSubmit()">提交</button>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- /.row -->
      </div>
      <!--*************************** content部分结束 ******************-->

      <!-- <footer class="footer text-center"> 2017 &copy; Ample Admin brought to you by themedesigner.in </footer> -->
    </div>
  {include file="common:js" /}
  {include file="common:footer" /}
  <script src="/assets/plugins/bower_components/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"></script>
  <script src="/assets/plugins/bower_components/jQuery-File-Upload/js/jquery.iframe-transport.js"></script>
  <script src="/web/js/edit.js"></script>

  <script type="text/javascript">
    var vm = new Vue({
      el: '#m_main',
      data() {
        return {
          sid: '{$sid}',
          name: "",
          master_teacher: "",
          assistant_teacher: "",
          teacher_list: []
        }
      },
      created() {
      },
      methods: {
        // 提交
        doSubmit(){
          var that = this;
          var param = {
            sid: that.sid,
            name: that.name,
            master_teacher: that.master_teacher,
            assistant_teacher: that.assistant_teacher,
          }

          axios.post('/dboard/classes/doCreateClasses', param,{headers: {'X-Requested-with':'XMLHttpRequest'}}).then(res => {
            // console.log(res);
            if(res.data.Code == 0){
              //请求成功
              alert(res.data.Msg);
              window.location.href = '/dboard/classes/lists';
            }else{
              alert(res.data.Msg)
            }
          }).catch(err => {
            console.log(err);
          })
        },
        teacherList(){
          var that = this;
          var param = {
            sid: that.sid,
          }
          axios.post('/dboard/teacher/teacherList', param,{headers: {'X-Requested-with':'XMLHttpRequest'}}).then(res => {
            // console.log(res);
            if(res.data.Code == 0){
              that.teacher_list = res.data.Data;
              console.log(that.teacher_list)
            }
          }).catch(err => {
            console.log(err);
          })
        },
      }
    })
  </script>
